From: Keir Fraser Date: Mon, 21 Jun 2010 08:58:17 +0000 (+0100) Subject: xend: fix "xm list hangs" X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~11901 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=df992155c8557babc598fc5e73be6554426233c2;p=xen.git xend: fix "xm list hangs" If a command hold domains_lock, "xm list" would hang for waiting for the lock. Such as creating many VMs at a script (such as 20), command of "xm list" could hang for long time(10 mins). I think domains_lock here only protect update(). So, we shouldn't do update before command of "list" really get this lock, but xm do need show the domain's information quickly. In this patch, if command couldn't get the domains_lock after 20 times trying, "xm list" would show the information of VMs without update(). Signed-off-by: James Song (Wei) --- diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index 888c2a7d6f..73fee7077b 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -824,10 +824,16 @@ class XendDomain: if type(state) == int: state = POWER_STATE_NAMES[state] state = state.lower() - - self.domains_lock.acquire() + resu = False + count = 0 + while True: + resu = self.domains_lock.acquire(0) + if resu or count < 20: + break + count += 1 try: - self._refresh(refresh_shutdown = False) + if resu: + self._refresh(refresh_shutdown = False) # active domains active_domains = self.domains.values() @@ -846,7 +852,8 @@ class XendDomain: POWER_STATE_NAMES[x._stateGet()].lower() == state, active_domains + inactive_domains) finally: - self.domains_lock.release() + if resu: + self.domains_lock.release() def list_sorted(self, state = DOM_STATE_RUNNING):